package com.smartleanx.module.hrm.app.risk;

import cn.hutool.core.collection.CollUtil;
import com.smartleanx.module.hrm.app.empRisk.EmployeeRiskHandle;
import com.smartleanx.module.hrm.eums.risk.RiskLevelEnum;
import com.smartleanx.module.hrm.eums.risk.RiskTypeEnum;
import com.smartleanx.module.hrm.service.companysystem.CompanySystemService;
import com.smartleanx.module.hrm.service.risk.RiskService;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Set;

/**
 * 规章制度
 *
 * @author tengcj
 * @since 2024/6/27
 */
@Component
public class RiskRegulationHandleService implements RiskHandle {

    public static final long RISK_ID = RiskTypeEnum.NO_REGULATION.getCode();

    @Resource
    private RiskService riskService;

    @Resource
    private CompanySystemService companySystemService;

    @Override
    public Long type() {
        return RISK_ID;
    }

    @Override
    public void handleRisk(Set<Long> recordIdList) {
        if (CollUtil.isEmpty(companySystemService.getAllCompanySystem())) {
            riskService.addRisk(null, RISK_ID, RiskLevelEnum.MAJOR.getLevel(), null);
        } else {
            riskService.deleteRisk(null, RISK_ID, null);
        }
    }
}
